package top.aiprogram.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import top.aiprogram.user.entity.Student;
import top.aiprogram.user.service.StudentService;


/**
 * Created by xqh on 2017/6/27.
 */
@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/test")
    public String testUser(@RequestBody Student student) {

        studentService.creatStudent(student);
       /* User user = new User();
        user.setId(22);
        user.setName("张三");
        modelMap.addAttribute("user", user);*/
        return "user";

    }

    @RequestMapping("/demo")
    public String demoUser() {
        return "demo";
    }

    /*@RequestMapping("/upload")
    public String upload(MultipartFile file, HttpServletRequest request) throws IOException {

        String name=file.getOriginalFilename();
        File uploadFile=new File("/"+name);

        file.transferTo(uploadFile);

        return "demo";
    }

    @RequestMapping("/down")
    public ResponseEntity<byte[]> download() throws IOException {
        String path="E:\\1.png";
        File file=new File(path);
        HttpHeaders headers=new HttpHeaders();
        headers.setContentDispositionFormData("attachment",path);
        headers.setContentType(MediaType.IMAGE_PNG);
        return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
    }*/
}
